package cn.ming.wfchat.app.me.activity;

import android.content.Intent;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import cn.ming.wfchat.R;
import cn.ming.wfchat.app.me.fragemt.CurrencyFjFragemt;
import cn.ming.wfchat.app.me.fragemt.CurrencyUsdtFragemt;
import cn.ming.wfchat.kit.WfcBaseActivity;

/**
 * @author luoming
 * created at 2020/8/11 3:04 PM
 * 我的资产
 */
public class MyAssetsActivity extends WfcBaseActivity {


    @BindView(R.id.viewpager)
    ViewPager viewpager;

    private List<Fragment> fragmentList;

    @Override
    protected int contentLayout() {
        return R.layout.my_assets_activity;
    }

    @Override
    protected void afterViews() {
        super.afterViews();
        setTitle("资产");
        setTvRight("流水记录");
        tvRight.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MyAssetsActivity.this, MoneyFlowingWaterActivity.class);
                startActivity(intent);
            }
        });
        initDate();
    }

    void initDate() {
        fragmentList = new ArrayList<>();
        fragmentList.add(CurrencyUsdtFragemt.newInstance());
        fragmentList.add(CurrencyFjFragemt.newInstance());
        viewpager.setAdapter(new Adapter(getSupportFragmentManager()));

    }


    class Adapter extends FragmentStatePagerAdapter {
        public Adapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            return fragmentList.get(position);
        }

        @Override
        public int getCount() {
            return fragmentList.size();
        }

        @Override
        public float getPageWidth(int position) {
//            if (position == fragmentList.size() - 1) {
//                return 0.9f;
//            }
            return 0.9f;
        }

    }
}
